package server

import (
	"github.com/gofiber/fiber/v2"
	"time"
)


// path: ./video/<sha256>, name: "ZH-CN-xxxx",
func Run(addr, port string) {
	app := fiber.New()

	app.Get("/ping", func(c *fiber.Ctx) error {
		return c.SendString("pong " + time.Now().Format("2006-01-02 15:04:05"))
	})

	app.Static("/video", "./www/video", fiber.Static{
		ByteRange: true,  //  enable byte-range request support
		Browse:    false, // 可选：禁用目录浏览
		MaxAge:    3600,  // 可选：设置缓存时间
	})

	app.Static("/", "./www/page")

	app.Listen(addr + ":" + port)
}
